package cn.hdu.liang.initialization;

class Bowl {
    Bowl(int marker) {
        System.out.println("Bowl(" + marker + ")");
    }

    void bowlF1(int marker) {
        System.out.println("bowlF1(" + marker + ")");
    }
}

class Table {
    static Bowl tableBowl1 = new Bowl(1);
    static Bowl tableBowl2 = new Bowl(2);

    Table() {
        System.out.println("Table()");
        tableBowl2.bowlF1(1);
    }

    void tableF2(int marker) {
        System.out.println("tableF2(" + marker + ")");
    }
}

class Cupboard {
    static Bowl cupBowl4 = new Bowl(4);
    static Bowl cupBowl5 = new Bowl(5);
    Bowl cupBowl3 = new Bowl(3);

    Cupboard() {
        System.out.println("Cupboard()");
        cupBowl4.bowlF1(2);
    }

    void cupF3(int marker) {
        System.out.println("cupF3(" + marker + ")");
    }
}

public class StaticInitialization {
    static Table table = new Table();
    static Cupboard cupboard = new Cupboard();

    public static void main(String[] args) {
        System.out.println("Creating new Cupboard() in main");
        System.out.println();
        new Cupboard();
        System.out.println("Creating new Cupboard() in main");
        System.out.println();
        new Cupboard();
        table.tableF2(1);
        cupboard.cupF3(1);
    }

}
